import { getStore, setStore } from "@/utils/store";
import api from "@/api";
import router from "@/router";

export default {
  state: {
    user: getStore("token") ? getStore("token").user : {}
  },

  mutations: {
    SET_USER: (state, user) => {
      state.token = user;
    }
  },
  actions: {
    // 登录
    /*eslint no-unused-vars:0*/
    Login({ commit }, loginForm) {
      api.post("login", loginForm).then(res => {
        setStore("token", res.userInfo);
        router.push("/home");
      });
    }
  }
};
